import {get,post,setToken} from '../utils/requst'
import Vue from 'vue';
//自定义一个插件
export default {
    //插件中必须包含一个install方法
    install:function (vue) {
        //给vue混入成员
        Vue.mixin({
            methods: {
                $get(url,params){
                    console.log(222222);
                    return get(url,params)
                },
                $post(url,params){
                    return post(url,params)
                },
                $setToken(token){
                    setToken(token)
                },
                //错误信息提示框
                $msg_e(message,time){
                    this.$message({
                        message,
                        type: 'warning',
                        time: time
                      });
                },
                $msg_s(message,time){
                    this.$message({
                        message,
                        type: 'success',
                        time: time
                      });
                },
                $msg_i(message,time){
                    this.$message({
                        message,
                        type: 'info',
                        time: time
                      });
                },
                $con_firm(message,type,success,fail){
                    this.$confirm(message, type, {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                      }).then(success).catch(fail);          
                }
            }
        })
    }
}